revealer: Fully set the target state if unmapped during animation
authorCarlos Garnacho <carlosg@gnome.org>
Wed, 19 Dec 2018 18:26:04 +0000 (19:26 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Wed, 19 Dec 2018 19:53:40 +0000 (20:53 +0100)
If the revealer is told do animate and then unrealize itself, we do
(correctly) stop the animation, but used to do a shortcut where we
just set the target state as current.

Other things are dependent on the animation properly finishing though,
like the contained widget child visibility. This may lead to inconsistent
state where gtk_revealer_get_child_revealed() returns TRUE but the child
widget is unmapped, or vice-versa.

Fully finish the animation here, so the child state is coherent the next
time the revealer is mapped. We can also skip notifying on the property
since it will be handled by gtk_revealer_set_position().

gtk/gtkrevealer.c

index 92a33da86825854c014a32fbe794729edf3536ab..d1245d22fbe383762e39e226a6dc47901515092b 100644 (file)
@@ -111,6 +111,9 @@ static void gtk_revealer_measure (GtkWidget      *widget,
 static void     gtk_revealer_snapshot                            (GtkWidget     *widget,
                                                                   GtkSnapshot   *snapshot);
 
+static void     gtk_revealer_set_position (GtkRevealer *revealer,
+                                           gdouble      pos);
+
 G_DEFINE_TYPE_WITH_PRIVATE (GtkRevealer, gtk_revealer, GTK_TYPE_BIN)
 
 static void
@@ -202,10 +205,8 @@ gtk_revealer_unmap (GtkWidget *widget)
 
   /* Finish & stop the animation */
   if (priv->current_pos != priv->target_pos)
-    {
-      priv->current_pos = priv->target_pos;
-      g_object_notify_by_pspec (G_OBJECT (revealer), props[PROP_CHILD_REVEALED]);
-    }
+    gtk_revealer_set_position (revealer, priv->target_pos);
+
   if (priv->tick_id != 0)
     {
       gtk_widget_remove_tick_callback (GTK_WIDGET (revealer), priv->tick_id);